<!-- <roc-table
	v-if="tableFdList.length"
	:tableFdList="tableFdList"
	:tableList="tableList"
	:tableFdListJson="tableFdListJson"
	:queryForm="queryForm"
	:keyValueDatasObj="keyValueDatasObj"
	@handleEdit="handleEdit"
	@handleDel="handleDel"
	@handleDetail="handleDetail"
></roc-table> -->

<template>
	<view class="roc-table">
		<!-- <wyb-table
			ref="wyb-table"
			:headers="tableFdList"
			:default-col-width="220"
			:contents="tableList"
			:font-size="[25]"
			header-bg-color="#EFEFF4"
			first-col-bg-color="#fff"
			:cancelable="false"
		/> -->
		<uni-table :border="true" :stripe="true">
			<uni-tr>
				<uni-th align="center" v-for="item in tableFdListJson" :key="item.field">
					<text v-if="item.type == 'input'">
						{{ item.title }}
						<text v-if="item.children != undefined && item.children[0].children[0] != ''">
							({{ item.children[0].children[0] }})
						</text>
					</text>
					<text v-else>{{ item.title }}</text>
				</uni-th>
				<uni-th align="center">操作</uni-th>
			</uni-tr>
			<uni-tr v-for="row in tableList" :key="row.id">
				<uni-td align="center" v-for="item in tableFdListJson" :key="item.field">
					<!-- 单元格显示内容处理 -->
					<template v-if="item.type == 'select' || item.type == 'checkbox'">
						<text
							v-for="(vItem, vIndex) in row[item.field].split(',')"
							:key="vIndex"
							:class="keyValueDatasObj[item.field] && keyValueDatasObj[item.field][`class${row[item.field]}`]"
						>
							{{ keyValueDatasObj[item.field] && keyValueDatasObj[item.field][vItem] }}
							<text v-if="vIndex < row[item.field].split(',').length - 1">,</text>
						</text>
					</template>
					<template v-else-if="item.type == 'radio'">
						<text :class="keyValueDatasObj[item.field] && keyValueDatasObj[item.field][`class${row[item.field]}`]">
							{{ keyValueDatasObj[item.field] && keyValueDatasObj[item.field][row[item.field]] }}
						</text>
					</template>
					<template v-else-if="item.type == 'cascader'">
						<text
							v-for="(vItem, vIndex) in row[item.field].split(',')"
							:key="vIndex"
							:class="keyValueDatasObj[item.field] && keyValueDatasObj[item.field][`class${row[item.field]}`]"
						>
							{{ keyValueDatasObj[item.field] && keyValueDatasObj[item.field][vItem] }}
							<text v-if="vIndex < row[item.field].split(',').length - 1">/</text>
						</text>
					</template>
					<!-- 千分位 -->
					<template
						v-else-if="item.fieldType == 'int' || (item.type == 'input' && item.props && item.props.type == 'number')"
					>
						<text>{{ row[item.field] | kgRule }}</text>
					</template>
					<template v-else-if="item.type == 'datePicker'">
						<text>{{ row[item.field] == '2000-01-01T00:00:00' ? '' : row[item.field] }}</text>
					</template>
					<template v-else>
						<text>{{ row[item.field] }}</text>
					</template>
				</uni-td>
				<uni-td align="center">
					<template>
						<roc-btn type="primary" text="编辑" @click.native="handleEdit(row)"></roc-btn>
						<roc-btn type="error" text="删除" @click.native="handleDel(row)"></roc-btn>
						<roc-btn type="warning" text="详情" @click.native="handleDetail(row)"></roc-btn>
					</template>
				</uni-td>
			</uni-tr>
		</uni-table>
	</view>
</template>

<script>
export default {
	name: 'roc-table',
	props: {
		// 字段
		tableFdList: {
			type: Array,
			default() {
				return [];
			}
		},
		// 数据
		tableList: {
			type: Array,
			default() {
				return [];
			}
		},
		// 字段fcjson
		tableFdListJson: {
			type: Array,
			default() {
				return [];
			}
		},
		// json api数据
		keyValueDatasObj: {
			type: Object,
			default() {
				return {};
			}
		}
	},
	data() {
		return {};
	},
	methods: {
		handleEdit(row) {
			this.$emit('handleEdit', row);
		},
		handleDel(row) {
			this.$emit('handleDel', row);
		},
		handleDetail(row) {
			this.$emit('handleDetail', row);
		}
	}
};
</script>

<style lang="scss"></style>
